<?php
    $status = array('Pendiente', 'En Progreso', 'Revisando', 'Revisado', 'Rechazado', 'Completado');
?>
<article class="module width_full">
    <header><h3>Detalle de la orden</h3></header>
    <div class="module_content">
        <fieldset>
            <table>
                <tr>
                    <td><label>Codigo de Orden </label></td>
                    <td><span><?php echo $this->details->code ?></span></td>
                </tr>
                <tr>
                    <td><label>Titulo:</label></td>
                    <td><span><?php echo $this->details->title ?></span></td>
                </tr>
                <tr>
                    <td><label>Descripci&oacute;n:</label></td>
                    <td><span><?php echo $this->details->description ?></span></td>
                </tr>
                <tr>
                    <td><label>Fecha de inicio</label></td>
                    <td><span><?php echo $this->details->create_date ?></span></td>
                </tr>
                <tr>
                    <td><label>Fecha limite</label></td>
                    <td><span><?php echo $this->details->end_date ?></span></td>
                </tr>
                <tr>
                    <td><label>Cambio Brief:</label></td>
                    <td><span><?php echo ($this->details->change_brief != '') ? $this->details->change_brief : 'No' ?></span></td>
                </tr>
                <tr>
                    <td><label>Trabajo Cambios</label></td>
                    <td><span><?php echo ($this->details->change_job != '') ? $this->details->change_job : 'No' ?></span></td>
                </tr>
                <tr>
                    <td><label>Nueva Fecha Entrega</label></td>
                    <td><span><?php echo ($this->details->new_date_limit != '') ? $this->details->new_date_limit : 'No' ?></span></td>
                </tr>
            </table>
            <br/>
            <?php
            $st = $status[$this->details->status];
            if ($st == 'Revisado' || $st == 'En Progreso') {
                ?>        
                <form method="POST" action="<?php echo $this->url(); ?>">
                    <table>
                        <tr>
                            <td colspan="2"><label>Actividad</label></td>
                        </tr>
                        <tr>
                            <td><label>Estado:</label></td>
                            <td>
                                <input type="hidden" name="id_orden" id="id_order" value="<?php echo $this->details->id; ?>"/>
                                <span>
                                    <select id="status" name="status" style="width: 120px;">
                                        <option value="2" <?php echo ($this->details->status == 2) ? 'selected="selected"' : ''; ?>>Revisando</option>
                                        <option value="3" <?php echo ($this->details->status == 3) ? 'selected="selected"' : ''; ?>>Revisado</option>
                                        <option value="5" <?php echo ($this->details->status == 5) ? 'selected="selected"' : ''; ?>>Completado</option>
                                    </select>
                                    <input type="submit" name="change_status" id="change_status" value="Cambiar"/>
                                </span>
                            </td>
                        </tr>
                        <tr>
                            <td><label>Mensaje</label></td>
                            <td><textarea name="message" id="message"></textarea></td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <table class="table-simple">
                                    <tr>
                                        <th>Mensaje</th>
                                        <th>Fecha</th>
                                        <th>Usuario</th>
                                    </tr>    
                                    <?php foreach ($this->messages as $msg) : ?>
                                        <tr>
                                            <td><?php echo $msg->message ?></td>
                                            <td><?php echo $msg->create_date ?></td>
                                            <td><?php echo $msg->nombre.' '.$msg->apellidos ?></td>
                                        </tr>     
                                    <?php endforeach; ?>
                                </table>
                            </td>
                        </tr>
                    </table>
                </form>
            <?php }else { ?>
                <table class="table-simple">
                    <tr>
                        <th>Mensaje</th>
                        <th>Fecha</th>
                        <th>Usuario</th>
                    </tr>    
                    <?php foreach ($this->messages as $msg) : ?>
                        <tr>
                            <td><?php echo $msg->message ?></td>
                            <td><?php echo $msg->create_date ?></td>
                            <td><?php echo $msg->nombre.' '.$msg->apellidos ?></td>
                        </tr>     
                    <?php endforeach; ?>
                </table>
            <?php } ?>
        </fieldset>

        <article class="breadcrumbs" style="margin-top: 5px;">
            <a href="<?php echo $this->url(array('module' => 'attachment', 'action' => 'index', 'id' => $this->details->id)) ?>">Adjuntar archivos</a> 
            <div class="breadcrumb_divider"></div> 
            <a href="<?php echo $this->url(array('action' => 'index', 'id' => null)) ?>">Volver</a> 
        </article>
    </div>
    <footer></footer>
</article>

